/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidade.persistencia;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author victorinox
 */
@Entity
@Table(name = "opercao_extra", catalog = "carlossa03", schema = "")
@NamedQueries({@NamedQuery(name = "OpercaoExtra.findAll", query = "SELECT o FROM OpercaoExtra o"), @NamedQuery(name = "OpercaoExtra.findByOperacaoExtraId", query = "SELECT o FROM OpercaoExtra o WHERE o.operacaoExtraId = :operacaoExtraId")})
public class OpercaoExtra implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "operacao_extra_id")
    private Integer operacaoExtraId;
    @JoinColumn(name = "venda_id", referencedColumnName = "venda_id")
    @ManyToOne
    private Venda vendaId;
    @JoinColumn(name = "folha_pagamento_id", referencedColumnName = "folha_pagamento_id")
    @ManyToOne
    private FolhaPagamento folhaPagamentoId;
    @JoinColumn(name = "compra_id", referencedColumnName = "compra_id")
    @ManyToOne
    private Compra compraId;
    @JoinColumn(name = "manutencao_id", referencedColumnName = "manutencao_id")
    @ManyToOne
    private Manutencao manutencaoId;
    @JoinColumn(name = "operacao_extra_tipo_id", referencedColumnName = "operacao_extra_tipo_id")
    @ManyToOne(optional = false)
    private OperacaoExtraTipo operacaoExtraTipoId;
    @Column(name = "valor")
    private float valor;

    public OpercaoExtra() {
    }

    public OpercaoExtra(Integer operacaoExtraId) {
        this.operacaoExtraId = operacaoExtraId;
    }

    public Integer getOperacaoExtraId() {
        return operacaoExtraId;
    }

    public void setOperacaoExtraId(Integer operacaoExtraId) {
        this.operacaoExtraId = operacaoExtraId;
    }

    public Venda getVendaId() {
        return vendaId;
    }

    public void setVendaId(Venda vendaId) {
        this.vendaId = vendaId;
    }

    public FolhaPagamento getFolhaPagamentoId() {
        return folhaPagamentoId;
    }

    public void setFolhaPagamentoId(FolhaPagamento folhaPagamentoId) {
        this.folhaPagamentoId = folhaPagamentoId;
    }

    public Compra getCompraId() {
        return compraId;
    }

    public void setCompraId(Compra compraId) {
        this.compraId = compraId;
    }

    public Manutencao getManutencaoId() {
        return manutencaoId;
    }

    public void setManutencaoId(Manutencao manutencaoId) {
        this.manutencaoId = manutencaoId;
    }

    public OperacaoExtraTipo getOperacaoExtraTipoId() {
        return operacaoExtraTipoId;
    }

    public void setOperacaoExtraTipoId(OperacaoExtraTipo operacaoExtraTipoId) {
        this.operacaoExtraTipoId = operacaoExtraTipoId;
    }

     /**
     * @return the valor
     */
    public float getValor() {
        return valor;
    }

    /**
     * @param valor the valor to set
     */
    public void setValor(float valor) {
        this.valor = valor;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (operacaoExtraId != null ? operacaoExtraId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof OpercaoExtra)) {
            return false;
        }
        OpercaoExtra other = (OpercaoExtra) object;
        if ((this.operacaoExtraId == null && other.operacaoExtraId != null) || (this.operacaoExtraId != null && !this.operacaoExtraId.equals(other.operacaoExtraId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        if(operacaoExtraTipoId != null){
            return operacaoExtraTipoId.getNome();
        }

        return "persistencia.entidade.OpercaoExtra[operacaoExtraId=" + operacaoExtraId + "]";
    }

}
